package com.js.foodordersystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.js.foodordersystem.service.ReviewsService;
import com.js.foodordersystem.mapper.ReviewMapper;
import com.js.foodordersystem.entity.Review;
import org.springframework.stereotype.Service;
import com.js.foodordersystem.util.Result;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 存储用户对菜品的评价(Review)表服务实现类
 *
 * @author makejava
 * @since 2025-01-09 10:52:54
 */
@Service("reviewService")
public class ReviewServiceImpl extends ServiceImpl<ReviewMapper, Review> implements ReviewsService {


    @Override
    public Result selectAll(Review review, Integer limit, Integer page) {
        List<Map<String, Object>> list = baseMapper.selectAll(review, (page - 1) * limit, limit);
        HashMap<String, Object> result = new HashMap<>();
        result.put("count", baseMapper.selectAllCount(review));
        result.put("data", list);
        return Result.success(result);
    }
}

